package com.itheima.service.Impl;


import com.itheima.pojo.Setmeal;

import com.itheima.service.SetmealService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Slf4j
@Service
public class SetmealServiceImpl implements SetmealService {
 /*   @Autowired
    private SetmealMapper setmealMapper;
    @Autowired
    private CheckgroupMapper checkgroupMapper;
   @Autowired
    private RedisTemplate redisTemplate;
   @Autowired
   private CheckItemMapper checkItemMapper;


    *//**
     * 用户端根据id查询套餐
     * @param id
     * @return
     *//*
    @Override
    public Setmeal findById(Integer id) {
        SetmealPojo setmealPojo = setmealMapper.getById(id);

        if (setmealPojo != null){
            Setmeal setmeal = new Setmeal();
            BeanUtils.copyProperties(setmealPojo,setmeal);
            String checkGroupIds = setmealPojo.getCheckGroups();
            //将字符串转换成Integer集合
            String[] split = checkGroupIds.split(",");
            List<Integer> list = new ArrayList<>();
            for (String s : split) {
                list.add(Integer.parseInt(s));
            }
            List<CheckGroupPojo> checkGroups = checkgroupMapper.ByListId(list);


            for (CheckGroupPojo checkGroup : checkGroups) {
                List<CheckItemVo> checkItemVos = checkItemMapper.getById(checkGroup.getId());
                checkGroup.setCheckItems(checkItemVos);
            }
            setmeal.setCheckGroups(checkGroups);
            return setmeal;
        }
        return null;
    }

    @Override
    public List<Setmeal> getAll() {
        List<Setmeal> setmeals = setmealMapper.getAll();
        return setmeals;
    }*/
}
